/* proxyindex.rexx (0.63) 01-Aug-96
by mago@is-bremen.de
Written for httpproxy 0.14 alpha (30-Jul-96)
- Requirements: rexxtricks.library (Aminet), list, sort, type, echo, search
- Using this script without an argument, it creates three index files,
html sorted alpha. by time of file creation and an image page.
Plus an AmigaGuide file, wich enables you to delete single Proxy-files
by clicking on them (without warning). No Directorys are deleted.
- The file rexx:proxydel.rexx will be written. It's used by the guide-file.
- In an optional argument you can specify a searchpattern. All lines in
in the html and the images page containing this string are written into
{stem}g.html
- This script works only on the /http/ dir, so far.
*/
/********* config *********/
centdok = 0 /* center links or align left (bool) */
striport = 1 /* strip port numbers from URL's (bool) */
port = 80 /* port on wich your proxy is running */
fontsize = 3 /* Between 1 and 6 */
cachedir = 'data:cache/' /* With trailing slash! */
stem = 'data:cache' /* stem of the resulting files.
As there are:
{stem}.html the main page, only html
{stem}i.html the image page
{stem}ts.html all html pages sorted by time
{stem}g.html extract from both html pages
{stem}.guide to delete single cache entries */
/* If your LOCALE language is not German you may have to change this var */
monthident = 'Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez'
/**************************/
address command;parse arg pat;numfiles=0;status=1
/*'copy amitcp:bin/httpfetch ram:'*/
'Resident >nil: c:list'
if fontsize > 1 then do;bs=fontsize;hs=bs-1;end
else do;bs=fontsize;hs=bs;end
if length(pat) > 0 then call grep
'echo >'stem'cache.cont'
if ~show('L','rexxtricks.library') then call addlib('rexxtricks.library',0,-30,0)
tcnt=0;cnt=0;icnt=0
fn.0 = 14
fn.1 = '/* 'stem'.guide */;address command;parse arg string'
fn.2 = 'if index(string,"@@") == 0 then "delete >nil: "string'
fn.3 = 'else'
fn.4 = 'do'
fn.5 = ' off=index(string,@@)'
fn.6 = ' roff=off'
fn.7 = ' do while off > 0'
fn.8 = ' roff=off'
fn.9 = ' off=index(string,@@,off+1)'
fn.10= ' end'
fn.11= ' str=string'
fn.12= ' str=delstr(insert("!",str,roff+1),roff,1)'
fn.13= ' "delete >nil: "string" "str'
fn.14= 'end'
if ~writefile('rexx:proxydel.rexx',fn) then call ferr('rexx:proxydel.rexx')
if ~open(tmp,'t:pi.tmp',w) then call ferr('t:pi.tmp')
if ~open(tmpt,'t:timeindex.tmp',w) then call ferr('t:timeindex.tmp')
if ~open(tmpx,'t:logx.tmp',w) then call ferr('t:logx.tmp')
if ~open(tmpg,'t:logg.tmp',w) then call ferr('t:logg.tmp')
if ~open(guide,stem'.guide',w) then call ferr(stem'.guide')
call writeln(guide,'@database "Httpproxy.guide"')
call writeln(guide,'@node main "Delete HttpProxy (0.14) Cache"')
call close(guide)
call htmlhead
call getcont /* Explore the cachedir */
call writech(stdout,' 'numfiles' ')
do i=1 to numfiles-1 /* Seperate files into page and image */
if index(upper(ofn.i),'.MOV') == 0 & index(upper(ofn.i),'.MPG') == 0 & index(upper(ofn.i),'NPH-COUNT') == 0 & index(upper(ofn.i),'.JPEG') == 0 & index(upper(ofn.i),'.GIF') == 0 & index(upper(ofn.i),'.JPG') == 0 then
do
call writeln tmp,''str(ofn.i)''stat()'
'
call writeln tmpt,time.i' 'str(ofn.i)''stat()'
'
trace off
cnt=cnt+1
end
else
do
call writeln tmpx,''str(ofn.i)''stat()'
'
trace off
icnt=icnt+1
end
tcnt=tcnt+1
if tcnt == 101 then
do
tcnt=0
call writech(stdout,'*')
end
call writeln(tmpg,' @{ub}@{"'str(ofn.i)'" RX "rexx:proxydel.rexx 'ofp.i'"}@{ub}'stat())
trace off
end
call close(tmp);call close(tmpx);call close tmpg;call close tmpt;say
/* creation of the final files */
'Sort t:timeindex.tmp t:time.tmp'
call tsortpage
'Sort t:logg.tmp t:loge.tmp'
'Type >>'stem'.guide t:loge.tmp'
'Echo >>'stem'.guide @endnode'
'Sort t:pi.tmp t:log2.tmp';'Sort t:logx.tmp t:logy.tmp'
'Type >>'stem'.html t:log2.tmp'
if ~open(html,stem'.html',a) then call ferr(stem'.html')
call writeln(html,cenl(0)'')
call writeln(html,' Number of Pages: 'cnt'
')
call writeln(html,'')
call writeln(html,'
')
call close(html)
call gfxhead
'Type >>'stem'i.html t:logy.tmp'
call open(html,stem'i.html',a)
call writeln(html,cenl(0)'')
call writeln(html,' Number of images: 'icnt'
')
call writeln(html,'')
call writeln(html,'
' end else return '' tmod: /* DD-MMM-JJ HH:MM:SS -> JJMMDD HH to make it sortable and short */ return delstr(fd.i,1,7)||month(substr(fd.i,4,3))||substr(fd.i,1,2)' 'delstr(ft.i,3) month: /* convert the month abbrev. into number */ parse arg mt select when mt == word(monthident,1) then x='01' when mt == word(monthident,2) then x='02' when mt == word(monthident,3) then x='03' when mt == word(monthident,4) then x='04' when mt == word(monthident,5) then x='05' when mt == word(monthident,6) then x='06' when mt == word(monthident,7) then x='07' when mt == word(monthident,8) then x='08' when mt == word(monthident,9) then x='09' when mt == word(monthident,10) then x='10' when mt == word(monthident,11) then x='11' when mt == word(monthident,12) then x='12' otherwise nop end return x str: procedure parse arg t if index(t,'http://') > 0 then t=delstr(t,1,7) return t grep: if ~exists(stem'.html') then call ferr(stem'.html') if ~exists(stem'i.html') then call ferr(stem'i.html') if ~open(html,stem'g.html',w) then call ferr(stem'g.html') call writeln(html,'
"' exit ferr: parse arg fname say "Can't open: "fname exit htmlhead: /* html page */ if ~open(html,stem'.html',w) then call ferr(stem'.html') call writeln(html,'